package com.zzyl.serve.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.serve.dto.AlertDataDto;
import com.zzyl.serve.dto.HandleAlertDataDto;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Set;

import com.zzyl.serve.domain.AlertData;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 报警数据Mapper接口
 * 
 * @author liuyp
 * @date 2025-08-26
 */
@Mapper
public interface AlertDataMapper extends BaseMapper<AlertData>
{
    /**
     * 查询报警数据
     * 
     * @param id 报警数据主键
     * @return 报警数据
     */
    public AlertData selectAlertDataById(Long id);

    /**
     * 查询报警数据列表
     * 
     * @param alertData 报警数据
     * @return 报警数据集合
     */
    public TableDataInfo<AlertData> selectAlertDataList(AlertDataDto alertData);

    /**
     * 新增报警数据
     * 
     * @param alertData 报警数据
     * @return 结果
     */
    public int insertAlertData(AlertData alertData);

    /**
     * 修改报警数据
     * 
     * @param alertData 报警数据
     * @return 结果
     */
    public int updateAlertData(AlertData alertData);

    /**
     * 删除报警数据
     * 
     * @param id 报警数据主键
     * @return 结果
     */
    public int deleteAlertDataById(Long id);

    /**
     * 批量删除报警数据
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAlertDataByIds(Long[] ids);

    @Select("select user_name from sys_user where user_id = #{id}")
    String selectUserNameByUserId(Long id);

    @Update("update alert_data set processing_result = #{processingResult}, processing_time = #{processingTime}, processor_id = #{processorId}, processor_name = #{userName} ,status = 1 where user_id = #{userId} and iot_id = #{iotId} and status = 0")
    void updateHandAlerData(HandleAlertDataDto dto);


    @Update("update alert_data set processing_result = #{processingResult}, processing_time = #{processingTime}, processor_id = #{processorId}, processor_name = #{userName} ,status = 1 where id = #{id}")
    void updateHandAlerDataDto(HandleAlertDataDto dto);
}
